const path = require('path')

function resolve(dir) {
  return path.join(__dirname, dir)
}
// const BASE_API = 'http://332b03p509.zicp.vip'
module.exports = {
  publicPath: './',

  outputDir: 'dist',
  assetsDir: 'static',
  lintOnSave: process.env.NODE_ENV === 'development',
  devServer: {
    port: 8082,
  },
  productionSourceMap: false,
  chainWebpack: config => {
    config.module.rules.delete('svg')
    config.resolve.symlinks(true)
    config.resolve.alias
      .set('@', resolve('src'))
      .set('store', resolve('src/store'))
      .set('common', resolve('src/common'))
      .set('api', resolve('src/api'))
      .set('@/router', resolve('src/router'))
      .set('@/components', resolve('src/components'))
    config.module
      .rule('svg-sprite-loader')
      .test(/\.svg$/)
      .include.add(resolve('src/icons')) // 处理svg目录
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
  },
  configureWebpack: {
    performance: {
      hints: 'warning',
      // 入口起点的最大体积
      maxEntrypointSize: 50000000,
      // 生成文件的最大体积
      maxAssetSize: 30000000,
      // 只给出 js 文件的性能提示
      assetFilter: function (assetFilename) {
        return assetFilename.endsWith('.js')
      }
    }
  },
  transpileDependencies: ['vue-echarts', 'resize-detector']
}